package com.liqi.frame.comm.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liqi.frame.comm.po.Permission;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * 权限的数据访问对象
 * Created by liqi on 2017/8/2.
 */
public interface PermissionDao extends BaseMapper<Permission> {
    //根据用户ID获取权限的Set集合
    Set<String> findPermissionByUserId(@Param("userId") String userId);


    Permission getPermissionById(@Param("id") String id);
    List<Permission> getPermissionListWithName(@Param("permissionName") String permissionName,
                                               @Param("permissionType") String permissionType);

    List<Permission> getPermissionListWithNameByUserId(@Param("permissionName") String permissionName,
                                                       @Param("permissionType") String permissionType,
                                                       @Param("userId") String userId);
    List<Permission> getList();

    List<Permission> getMenuList();
    List<Permission> getOperationList();
    List<Permission> getMenuListByUserId(@Param("userId") String userId);
    List<Permission> getOperationListByUserId(@Param("userId") String userId);
    List<Permission> getOperationListByRoleId(@Param("roleId") String roleId);
    List<Permission> getMenuListByUsername(@Param("username") String username);
    List<Permission> getOperationListByUsername(@Param("username") String username);
    List<Permission> getMenuListByRoleId(@Param("roleId") String roleId);


    List<Permission> getPermissionsByKey(@Param("permissionKey") String permissionKey, @Param("permissionType") String permissionType);

    int insertObject(@Param("id") String id,
                     @Param("permissionKey") String permissionKey,
                     @Param("permissionName") String permissionName,
                     @Param("permissionType") String permissionType,
                     @Param("parentId") String parentId,
                     @Param("level") Integer level,
                     @Param("comment") String comment,
                     @Param("orderId") Float orderId,
                     @Param("target") String target,
                     @Param("href") String href);


    int updateObject(@Param("id") String id,
                     @Param("permissionKey") String permissionKey,
                     @Param("permissionName") String permissionName,
                     @Param("permissionType") String permissionType,
                     @Param("parentId") String parentId,
                     @Param("level") Integer level,
                     @Param("comment") String comment,
                     @Param("orderId") Float orderId,
                     @Param("target") String target,
                     @Param("href") String href);

    int deletePermissionById(@Param("id") String id);

    List<Permission> getPermissionListByRoleId(@Param("roleId") String roleId);

    List<Permission> getPermissionListByUserId(@Param("userId") String userId);


    int deletePermissionsByIds(@Param("ids") String[] ids);

    int deleteMenuListByParentId(@Param("parentId") String parentId);
}
